package com.jinglu.cloud.common.utils;

/**
 * @author lvzhenzhao
 * @date 2022/8/2-13:37
 **/
public class NumberGenerator {

    /**
     * 收货订单编号前缀
     */
    public static final String RECEIVE_ORDER_PREFIX = "ODR";

    /**
     * 发货订单编号前缀
     */
    public static final String DELIVER_ORDER_PREFIX = "ODS";

    /**
     * 盘点任务编号前缀
     */
    public static final String CHECK_TASK_PREFIX = "CK";

    /**
     * 拣货任务编号前缀
     */
    public static final String PICKING_TASK_PREFIX = "PK";

    /**
     * 打包任务编号前缀
     */
    public static final String PACKAGE_TASK_PREFIX = "PKG";

    /**
     * 购买套餐编号前缀
     */
    public static final String PURCHASE_SUITE_PREFIX = "PS";

    /**
     * 退库单编号前缀
     */
    public static final String RETURN_STOCK_PREFIX = "RS";

    /**
     * 清点任务编号前缀
     */
    public static final String COUNT_TASK_PREFIX = "CT";

    /**
     * 清点任务编号前缀
     */
    public static final String SHELVES_GOODS_PREFIX = "SG";

    /**
     * 包裹编号前缀
     */
    public static final String PACKAGED_PARCEL_PREFIX = "PPA";

    /**
     * 生成编号
     * @param prefix
     * @return
     */
    public static String generateNumber(String prefix) {
        SnowFlake snowFlake = new SnowFlake(0);
        long number = snowFlake.nextId();
        StringBuilder numberBuilder = new StringBuilder(prefix);
        numberBuilder.append(number);
        return numberBuilder.toString();
    }

    /**
     * 生成编号
     * @param prefix
     * @param machineId
     * @return
     */
    public static String generateNumber(String prefix, int machineId) {
        SnowFlake snowFlake = new SnowFlake(machineId);
        long number = snowFlake.nextId();
        StringBuilder numberBuilder = new StringBuilder(prefix);
        numberBuilder.append(number);
        return numberBuilder.toString();
    }

}
